<?php
/*
 * @subpackage Core Pass input tag attributes as key value pairs. For a list of allowable attributes, see http://www.w3schools.com/tags/tag_input.asp @uses $vars['default'] The default value to submit if not checked. Optional, defaults to 0. Set to false for no default. @uses $vars['class'] Additional CSS class
 */
$star_url = elgg_normalize_url ( 'mod/subjectmanage/graphics/star.png' );

if (isset ( $vars ['class'] )) {
	$vars ['class'] = "elgg-input-checkbox {$vars['class']}";
} else {
	$vars ['class'] = "elgg-input-checkbox";
}

$defaults = array (
		'default' => 0,
		'disabled' => false 
);

$vars = array_merge ( $defaults, $vars );

$default = $vars ['default'];
unset ( $vars ['default'] );
$name = "";

if (isset ( $vars ['name'] )) {
	$name = $vars ['name'];
} else {
	$name = "rating";
}
if (isset ( $vars ['checked'] )) {
	switch ($vars ['checked']) {
		case 1 :
			$checked1 = "checked";
			break;
		case 2 :
			$checked1 = "checked";
			$checked2 = "checked";
			break;
		case 3 :
			$checked1 = "checked";
			$checked2 = "checked";
			$checked3 = "checked";
			break;
		case 4 :
			$checked1 = "checked";
			$checked2 = "checked";
			$checked3 = "checked";
			$checked4 = "checked";
			break;
		case 5 :
			$checked1 = "checked";
			$checked2 = "checked";
			$checked3 = "checked";
			$checked4 = "checked";
			$checked5 = "checked";
			break;
	}
}
if(isset($vars['entity_guid'])){
	$entity_guid = $vars['entity_guid'];
}
echo <<<___HTML
<span class="rating-$entity_guid">
    
    <label for="rating-input-1-5" class="rating-star-$entity_guid $checked5"></label>
    
    <label for="rating-input-1-4" class="rating-star-$entity_guid $checked4"></label>
    
    <label for="rating-input-1-3" class="rating-star-$entity_guid $checked3"></label>
    
    <label for="rating-input-1-2" class="rating-star-$entity_guid $checked2"></label>
    
    <label for="rating-input-1-1" class="rating-star-$entity_guid $checked1"></label>
</span>
___HTML;

?>



<style>
.rating-<?php echo $entity_guid;?> {
	overflow: hidden;
	display: inline-block;
}

.rating-input-<?php echo $entity_guid?> {
	display: none;
	position: absolute;
	left: 0;
	top: -50px;
}


.rating-star-<?php echo $entity_guid;?> {
	float: right;
	display: block;
	width: 16px;
	height: 16px;
	background: url(<?php echo $star_url ?>) 0 -16px;
}

.checked {
	background-position: 0 0;
}
</style>